<!DOCTYPE html>
<html lang="en" xmlns:v-bind="http://www.w3.org/1999/xhtml"
      xmlns:v-on="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>旧汽车库存</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-store, must-revalidate">
    <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
    <meta http-equiv="expires" content="-1">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
          name="viewport">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" href="/dist/img/icon.png" type="image/x-icon">
    <!-- Bootstrap 3.3.6 -->
    <link rel="stylesheet" href="/dist/plugins/bootstrap/css/bootstrap.min.css">
    <!--字体-->
    <link rel="stylesheet" href="/dist/css/font-awesome.min.css">
    <!--图标-->
    <link rel="stylesheet" href="/dist/css/ionicons.min.css">
    <!--插件样式-->
    <link rel="stylesheet" href="/dist/plugins/select2/select2.min.css">
    <!--OA主样式-->
    <link rel="stylesheet" href="/dist/css/OA.min.css?t=39cd89cd">
    <link rel="stylesheet" href="/dist/css/skins/OA-skins.min.css?t=16f1e6f3">
    <link rel="stylesheet" href="/dist/plugins/fixedTable/fixed-table.css" />
    <style>
        .table > tbody > tr > td {
            height: 30px;
            max-height: 44px;
            overflow: hidden;
            padding: 0 2px;
        }

        .saveModle {
            width: 500px;
            height: 300px;
            position: fixed;
            top: 50%;
            left: 50%;
            margin-left: -250px;
            margin-top: -150px;
            background: #fff;
            border-radius: 10px;
            z-index: 1978;
            display: none;
            border: 1px solid #cfcfcf;
        }

        .saveModle .top {
            height: 34px;
            line-height: 34px;
            font-size: 14px;
            font-weight: bold;
            color: #333;
            padding-left: 7px;
            border-bottom: 1px solid #cfcfcf;
            background: #fff;
        }

        .saveModle .top .title {
            height: 32px;
            line-height: 32px;
            font-size: 14px;
            font-weight: bold;
            color: #333;
            float: left;
            background: #fff;
        }

        .saveModle .top .btn {
            font-size: 20px;
            width: 34px;
            height: 22px;
            line-height: 12px;
            display: inline-block;
            float: right;
        }

        .saveModle .top .btn:hover {
            color: red;
        }

        .saveModle .saveBtn {
            margin: 0 auto;
            margin-top: 35px;
            display: block;

        }
        .lineOne {
            text-align: left;
        }
        .lineOne span {
            max-height: 20px;
            line-height: 20px;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 1;
            text-align: left;
        }
        p{
            display: inline-block;
            float: left;
            margin-bottom: 0px;
            line-height: 25px;
            padding-right: 15px;
            color: #228bee;
            font-size: 14px;
        }
        .td-value span.lineOne {
            overflow: hidden;
            text-overflow: ellipsis;
            color: black !important;
            /*display: -webkit-box;*/
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 2;
            max-height: 34px;
        }
        .td-value {
            text-align: left !important;
            vertical-align: middle;
            word-wrap: break-word;
            color: black !important;
        }
        td{
            height:47.78px;
        }
        .td-value span {
            display: inline-block;
            overflow: hidden;
            padding-left: 0.06rem;
            word-wrap: break-word;
            color: black !important;
        }
        .fixed-table_body tr td{
            border-right: none;
            font-size: 12px;
            text-align: center;
        }
        .fixed-table_header tr th{
            border-right: none;
            background: yellow;
            font-weight: normal;
            font-size: 12px;
        }
        .content{
            padding:0;
        }
        .nav-tabs-custom>.nav-tabs>li.active{
            color: #2a8cec;
        }
        .nav-tabs-custom>.nav-tabs>li.active>a, .nav-tabs-custom>.nav-tabs>li.active:hover>a{
            background: #fff;
            color: #2a8cec;
            border-top-left-radius:0px;
            border-top-right-radius:0px;
        }
        .nav-tabs{
            border-bottom: 0px solid #ddd;
        }
        .nav-tabs-custom>.nav-tabs{
            /*border-bottom-color: #fff;*/
        }
        .nav-tabs-custom {
            box-shadow: 0 0px 0px rgba(0,0,0,0.1);
        }
        .fixed-table-box .fixed-table_header th{
            text-align: center;
        }
    </style>
</head>

<body>
<iframe id="ifExprot" style="width:0px;height:0px;display: none;" frameborder="0"></iframe>
<section class="content" id="app" v-cloak>
    <div class="div-td-content-more"><i></i></div>
    <!--<div class="nav-tabs-custom oaReportNav" style="margin:10px 0px;">-->
        <!--<ul class="nav nav-tabs pull-right" style="margin-bottom: 10px;" v-cloak>-->
            <!--<li @click="getDisplaceListNew(' ')" class="active">-->
                <!--<a href="#sales-chart" data-toggle="tab">全部(<span>{{count.allCount}}</span>)</a>-->
            <!--</li>-->
            <!--<li @click="getDisplaceListNew('提车在途')" :class="isActive('提车在途')?'active':''">-->
                <!--<a href="#sales-chart" data-toggle="tab">提车在途(<span>{{count.tcCount}}</span>)</a>-->
            <!--</li>-->
            <!--<li @click="getDisplaceListNew('库存')" :class="isActive('库存')?'active':''">-->
                <!--<a href="#sales-chart" data-toggle="tab">库存(<span>{{count.kcCount}}</span>)</a>-->
            <!--</li>-->
            <!--<li @click="getDisplaceListNew('交付在途')" :class="isActive('交付在途')?'active':''">-->
                <!--<a href="#sales-chart" data-toggle="tab">交付在途(<span>{{count.jfCount}}</span>)</a>-->
            <!--</li>-->
            <!--<li @click="getDisplaceListNew('已交')" :class="isActive('已交')?'active':''">-->
                <!--<a href="#sales-chart" data-toggle="tab">已交(<span>{{count.yjCount}}</span>)</a>-->
            <!--</li>-->
            <!--<li @click="getDisplaceListNew('移库在途')" :class="isActive('移库在途')?'active':''">-->
                <!--<a href="#sales-chart" data-toggle="tab">移库在途(<span>{{count.ykCount}}</span>)</a>-->
            <!--</li>-->
            <!--<li @click="getDisplaceListNew('退货在途')" :class="isActive('退货在途')?'active':''">-->
                <!--<a href="#sales-chart" data-toggle="tab">退货在途(<span>{{count.thCount}}</span>)</a>-->
            <!--</li>-->
            <!--<li @click="getDisplaceListNew('已退货')" :class="isActive('已退货')?'active':''">-->
                <!--<a href="#sales-chart" data-toggle="tab">已退货(<span>{{count.ythCount}}</span>)</a>-->
            <!--</li>-->
            <!--<input type="text" id="likeSelect" class="form-controll pull-left" style="width: 130px;height: 25px;"-->
                   <!--v-model="searchParams.key" placeholder="请输入关键字" size="12">-->
            <!--<input type="button" class="btn oaBtn pull-left btn-sm" style="margin-left: 10px" value="查询" class="oaBtn"-->
                   <!--@click="getListByKey()">-->
            <!--&lt;!&ndash;<button type="button" class="btn oaBtn pull-right btn-sm"-->
                    <!--@click="gotoDetail(0,'edit',1)"/>-->
            <!--新增入库</button>&ndash;&gt;-->
            <!--<button type="button"  class="btn oaBtn pull-right btn-sm"-->
                    <!--@click="exportExcel('2')"/>-->
            <!--导出旧车</button>-->
        <!--</ul>-->
    <!--</div>-->
    <div class="nav-tabs-custom oaReportNav" style="margin:10px 0px;">
        <!--下拉框联动-->
        <div class="pull-left" style="width:130px;">
            <select id="testCom" v-model="searchParams.companyName" class="form-control" @change="getBran"
                    style="height:26px;width: 130px;font-size:12px;line-height:25px;padding-top:0px;padding-bottom:0px;padding-left:6px;">
                <option selected value="购车公司">购车公司</option>
                <option v-for="itemC in itemsCom" v-bind:value="itemC.name">{{itemC.name}}</option>
            </select>
        </div>
        <div class="pull-left" style="margin-left:10px;">
            <select id="testBran" v-model="selectBran" class="form-control"
                    style="height:26px;width: 130px;font-size:12px;line-height:25px;padding-top:0px;padding-bottom:0px;padding-left:6px;"
                    @change="getType">
                <option selected value="品牌">品牌</option>
                <option v-for="itemB in itemsBran" v-bind:value="itemB.brandName">{{itemB.brandName}}</option>
            </select>
        </div>

        <div class="pull-left" style="width:130px;margin-left:10px;">
            <select id="testType" v-model="selectType" class="form-control"
                    style="height:26px;width: 130px;font-size:12px;line-height:25px;padding-top:0px;padding-bottom:0px;padding-left:6px;">
                <option selected value="汽车类型">汽车类型</option>
                <option v-for="itemT in itemsType" v-bind:value="itemT.name">{{itemT.name}}</option>
            </select>
        </div>
        <div class="pull-left" style="margin-left: 10px;">
            <select id="testMod" v-model="selectMod" class="form-control"
                    style="height:26px;width: 130px;font-size:12px;line-height:25px;padding-top:0px;padding-bottom:0px;padding-left:6px;"
                    @change="show()">
                <option selected value="型号">型号</option>
                <option v-for="itemMo in itemsMod" v-bind:value="itemMo.modelName">{{itemMo.modelName}}</option>
            </select>
        </div>
        <div class="pull-left" style="margin-left: 10px;">
            <select id="testState" v-model="selectState" class="form-control"
                    style="height:26px;width: 130px;font-size:12px;line-height:25px;padding-top:0px;padding-bottom:0px;padding-left:6px;">
                <!--@change="sel()"-->
                <option selected value="状态">状态</option>
                <option v-for="option in stateList" v-bind:value="option.value">{{option.name}}</option>
            </select>
        </div>
        <div class="pull-left" style="margin-left: 10px;">
            <input type="text" id="likeSelect" class="form-controll pull-left" style="width: 130px;height: 25px;"
                   v-model="searchParams.key" placeholder="请输入关键字" size="12">
            <input type="button" class="btn oaBtn pull-left btn-sm" style="margin-left: 10px" value="查询" class="oaBtn"
                   @click="sel()">
            <input type="button" class="btn oaBtn pull-left btn-sm" style="margin-left: 10px" value="新增入库" class="oaBtn" @click="addOldCar()" v-if="roleName=='订货支持'">
        </div>
        <button type="button"  class="btn oaBtn pull-right btn-sm"
                @click="exportExcel('2')"/>
        导出旧车</button>
    </div>
    <div class="box-body no-padding" style="overflow: auto;position: relative;margin-top:10px;display: inline-block; " id="scrollDiv">
        <div id="progress" class="wyui-progress"></div>
        <div class="fixed-table-box head-fixed">
            <!-- 表头 start -->
            <div class="fixed-table_header-wraper">
                <table class="fixed-table_header" cellspacing="0" cellpadding="0" border="0">
                    <thead>
                    <tr>
                        <th style="width:37px;">序号</th>
                        <th style="width:85px;text-align: left;padding-left: 2px;">归属公司</th>
                        <th style="width:85px;text-align: left;padding-left: 2px;">库存地</th>
                        <th style="width:61px;text-align: left;padding-left: 2px;">品牌</th>
                        <th style="width:61px;text-align: left;padding-left: 2px;">汽车类型</th>
                        <th style="width:52px;text-align: left;padding-left: 2px;">型号</th>
                        <th style="width:140px;">车架号</th>
                        <th style="width:61px;">出厂年份</th>
                        <th style="width:50px;">公里数</th>
                        <th style="width:61px;">库存状态</th>
                        <th style="width:107px;">审核状态</th>
                        <th  style="min-width: 40px;">备注</th>
                        <th style="width:120px;">操作</th>
                        <th style="width: 17px;"></th>
                    </tr>
                    </thead>
                </table>
            </div>
            <div class="fixed-table_body-wraper iframeKC">
                <table class="fixed-table_body table-hover" cellspacing="0" cellpadding="0" border="0"
                       style="width: 100%;">
                    <tbody id="tbList">
                    <tr v-for="(item,i) in list">
                        <td style="width:37px;">{{i+1}}</td>
                        <td style="width:85px;text-align: left;" v-if="item.companyName">{{item.companyName}}</td>
                        <td style="width:85px;text-align: left;" v-else>-</td>
                        <td style="width:85px;text-align: left;"><span v-html="showDz(item)"></span></td>
                        <td style="width:61px;text-align: left;" v-if="item.brandName">{{item.brandName}}</td>
                        <td style="width:61px;text-align: left;" v-else>-</td>
                        <td style="width:61px;text-align: left;" v-if="item.replacementType">{{item.replacementType}}</td>
                        <td  style="width:61px;text-align: left;" v-else>-</td>
                        <td style="width:52px;text-align: left;" v-if="item.modelName">{{item.modelName}}</td>
                        <td style="width:52px;text-align: left;" v-else>-</td>
                        <td v-if="item.sequence" style="width:140px;color: #2a8cec;cursor: pointer;" @click="gotoDetail(item.id,'look',0)" style="color:#228bee;text-align: left;">{{item.sequence}}
                        </td>
                        <td style="width:140px;text-align: left;" v-else>-</td>
                        <td style="width:61px;" v-if="item.factoryDate">{{item.factoryDate}}</td>
                        <td style="width:61px;" v-else>-</td>
                        <td style="width:50px;" v-if="item.kilometers">{{item.kilometers}}</td>
                        <td style="width:50px;" v-else>-</td>
                        <td style="width:61px;" v-if="item.state">{{item.state}}</td>
                        <td style="width:61px;" v-else>-</td>
                        <td style="width:107px;" v-html="convertAuditFlagToName(item)"></td>
                        <td  style="min-width: 40px;" class='td-tanZongStyle-line'><span class="lineOne">{{item.remark}}</span></td>
                        <td style="width:120px;">
                            <a href="javascript:void(0);" v-if="showABtn(item,'audit')"
                               @click="gotoDetail(item.id,'audit',0)">&nbsp;审核&nbsp;</a>
                            <a style="text-align: center;color: #CCCCCC" v-else>&nbsp;审核&nbsp;</a>

                            <a href="javascript:void(0);" v-if="showABtn(item,'edit')"
                               @click="gotoDetail(item.id,'edit',0,item.auditFlag,item.state)">&nbsp;编辑&nbsp;</a>
                            <a style="text-align: center;color: #CCCCCC" v-else>&nbsp;编辑&nbsp;</a>
                            <a href="javascript:void(0);" v-if="showABtn(item,'del')"
                               @click="removeById(item.id)">&nbsp;删除&nbsp;</a>
                            <a style="text-align: center;color: #CCCCCC" v-else>&nbsp;删除&nbsp;</a>
                            <br>
                            <a href="javascript:void(0);"
                               @click="gotoDetailOut(item.id,item.modelName,item.storeAddress,'out',item.fkCompanyId)"
                               v-if="showABtn(item,'out')">出库&nbsp;</a>
                            <a style="text-align: center;color: #CCCCCC" v-else>出库&nbsp;</a>
                            <a href="javascript:void(0);"
                               @click="gotoDetailOut(item.id,item.modelName,item.storeAddress,'move',item.fkCompanyId)"
                               v-if="showABtn(item,'out')">&nbsp;移库&nbsp;</a>
                            <a style="text-align: center;color: #CCCCCC" v-else>&nbsp;移库&nbsp;</a>
                            <a href="javascript:void(0);"
                               @click="gotoDetailOut(item.id,item.modelName,item.storeAddress,'return')"
                               v-if="showABtn(item,'return')">&nbsp;退货&nbsp;</a>
                            <a style="text-align: center;color: #CCCCCC" v-else>&nbsp;退货&nbsp;</a>
                        </td>
                        <template v-if="list.length>=18">
                            <td style="width: 0px;"></td>
                        </template>
                        <template v-else>
                            <td style="width: 17px;" ></td>
                        </template>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</section>
<!--JQ-->
<script src="https://file.ggxqce.com/web/jquery-2.2.3.min.js"></script>
<!--插件JS-->
<script src="https://file.ggxqce.com/web/bootstrap.min.js"></script>
<!--框架已定义 JS-->
<script src="/dist/js/app_iframe.js?t=7e54a132"></script>
<!--oa自定义  JS-->
<script src="/dist/js/oa.js?t=558d0414"></script>
<script src="https://file.ggxqce.com/web/vue.min.js"></script>
<script src="/dist/plugins/select2/select2.full.min.js"></script>
<script type="text/javascript" src="/dist/plugins/lhgdialog/lhgdialog.min.js?self=true"></script>
<script src="/dist/plugins/fixedTable/fixed-table.js"></script>
<script>
    $(function () {
        $("body").on("click", ".lineOne,.lineTwo", function (e) {
            if ($(".div-td-content-more").is(":hidden")) {
                var text = $(this).text();
                if (text != "") {
                    text = "<i></i>" + text;
                    $(".div-td-content-more").html(text).css({
                        "width": $(this).outerWidth() + 12 + "px",
                        "left": $(this).offset().left - 6,
                        "top": ($(this).offset().top + $(this).outerHeight()) + "px"
                    }).show();
                    e.stopPropagation();
                }
            } else {
                $(".div-td-content-more").hide();
            }
        });
        $("body").on("click", ".div-td-content-more", function (e) {
            e.stopPropagation();
        });
        $("body").on("click", function () {
            $(".div-td-content-more").hide();
        });
    });
</script>
<script type="text/javascript">
    function refresh() {
        location.reload();
    }
    var app = new Vue({
        el: '#app',
        data: {
            roleName:getCurrentUser().roleName,
            searchParams: {
                type: '2',//1-旧挖掘机，2-旧汽车，3-旧房屋，
                companyName: '购车公司',
                fkCompanyId: '',
                brandName: '',
                modelName: '',
                sequence: '',
                replacementType: '',
                state: '',
                key: '',
                userId: getCurrentUser().id,
            },
            count: {
                allCount: '',
                tcCount: '',
                kcCount: '',
                jfCount: '',
                yjCount: '',
                ykCount: '',
                noCount: '',
                thCount: '',//退货在途
                ythCount: '',//已退货
            },
            currentUser: getCurrentUser(),
            list: [],
            itemsBran: [],
            itemsType: [
                {name:'汽车'}
            ],
            itemsCom: [],
            itemsMod: [],
            itemState: [],
            selectCom: "购车公司",
            selectBran: "品牌",
            selectMod: "型号",
            selectType: "汽车类型",
            selectState: "状态",
            stateList: [
                {name: '全部', value: '全部'},
                {name: '提车在途', value: '提车在途'},
                {name: '库存', value: '库存'},
                {name: '交付在途', value: '交付在途'},
                {name: '已交', value: '已交'},
                {name: '移库在途', value: '移库在途'},
                {name: '退货在途', value: '退货在途'},
                {name: '已退货', value: '已退货'},
            ],
            sampleParmsList: {
                main: {
                    modelName: "",
                }
            }

        },
        methods: {
            //            获取公司
            getBran: function () {
                var that = this;
                var s = that.searchParams.companyName;
                that.selectBran = '请选择品牌';
                that.selectType = '请选择设备类型';
                that.selectMod = '请选择型号';
                that.selectStock = '请选择库存地';
                that.selectBucket = '请选择铲斗配置';
                var data = {'companyId': s.toString()};
                $.wyui.postMethod('/deviceDisplace/getDisplaceByBrandName.json',{'type':"2"}, function (r) {
                    that.itemsBran = r;
                    that.selectBran = '品牌';
                    that.selectType = '汽车类型';
                    that.selectMod = '型号';
                })
                $.wyui.postMethod('/company/getCompanyById.json', {id: s.toString()}, function (r) {
                    that.stocks = r.stock;
                })
            },
            //获取品牌
            getType:function () {
                var that = this;
                that.selectType = '请选择设备类型';
                that.selectMod = '请选择型号';
                that.selectStock = '请选择库存地';
                that.selectBucket = '请选择铲斗配置';
                $.wyui.postMethod('/deviceDisplace/getDisplaceByBrandName.json',{'type':"2"}, function (r) {
                    that.itemsBran = r;
                    that.selectType = '汽车类型';
                    that.selectMod = '型号';
                })
                $.wyui.postMethod('/deviceDisplace/getDisplaceByModelName.json',{'type':"2"}, function (r) {
                    that.itemsMod = r;
                })
            },
            //获取型号
            show: function () {
                var that = this;
                $.wyui.postMethod('/deviceDisplace/getDisplaceByModelName.json', {'type':"2"}, function (r) {
                    that.itemsMod = r;
                })
            },
            /*根据选中条件查询设备信息(无法获取传回来的records)*/
            sel: function () {
                var that = this;
                that.searchParams.state = that.selectState == '全部' ? '' : that.selectState;
                var optionsCom = $("#testCom option:selected").text();
                var optionsType = $("#testType option:selected").text();
                var optionsBran = $("#testBran option:selected").text();
                var optionsMod = $("#testMod option:selected").text();
                var data = {
                    'companyName': optionsCom,
                    'brandName': optionsBran,
                    'modelName': optionsMod,
                    'deviceTypeName': optionsType,
                    'state': that.searchParams.state,
                    'key': that.searchParams.key,
                    userId: getCurrentUser().id,
                    'type':"2"
                };
                $.wyui.postMethod('/deviceDisplace/getDisplaceListNew.json', trimRN(data), function (r) {
                    that.list = r.records;
                    that.num = r.num;
                })
            },
            exportExcel: function (type) {
                var title="";
                if(type=="1"){
                    title="旧机导出"
                }else if(type=="2"){
                    title="旧车导出"
                }else{
                    title="旧房导出"
                }
                $.dialog({
                    content: 'url:/page/device/sample/displaceExport.html?type='+type,
                    title: title,
                    width: 1000,
                    height: 700,
                    max: true,
                    min: true,
                    lock: true
                });
                /*$('#ifExprot').attr('src', server.ip
                    + "/deviceDisplace/exportOldCar.json"
                );*/
            },
            showDz: function (item) {
                var html = item.storeAddress;
                if(html=="直发客户交机"){
                    return html;
                }else{
                    var sta=html.indexOf("省");
                    var pos=html.indexOf("市");
                    return html.substring(sta+1,pos+1);
                }
            },
            getDisplaceListNew: function (state) {
                var that = this;
                that.searchParams.state = state;
                $.wyui.postMethod("/deviceDisplace/getDisplaceListNew.json", that.searchParams, function (r) {
                    that.list = r.records;
                });
            },
            getListByKey: function () {
                var that = this;
                $.wyui.postMethod("/deviceDisplace/getDisplaceListNew.json", that.searchParams, function (r) {
                    that.list = r.records;
                    that.count = r.countList;
                });
            },
            addOldCar:function () {
                top.closeTabByPageId("qcgl");
                top.addTabs({
                    id: 'qcgl',
                    title: '旧车入库',
                    close: true,
                    url: '/device-new/sample/oldCarDetail.html?pageType=add'
                });
            },
            gotoDetail: function (id, pageType, isAdd,auditFlag,state) {
                var title="";
                if(pageType=="edit"){
                    if(isAdd=="0"){
                        title="旧汽车编辑"
                    }else if(isAdd=="1"){
                        title="旧汽车入库"
                    }
                }else{
                    title="旧汽车详情"
                }
                top.closeTabByPageId("qcgl");
                top.addTabs({
                    id: 'qcgl',
                    title: title,
                    close: true,
                    url: '/device/sample/oldCarDetail.html?pageType=' + pageType + "&&id=" + id + "&&isAdd=" + isAdd+"&&auditFlag="+auditFlag+"&&state="+state,
                });
                /*top.$.dialog({
                    content: 'url:/page/device/sample/oldCarDetail.html?pageType=' + pageType + "&&id=" + id + "&&isAdd=" + isAdd+"&&auditFlag="+auditFlag+"&&state="+state,
                    title: '旧汽车入库',
                    width: 904,
                    height: 535,
                    max: true,
                    min: true,
                    lock: true
                });*/
            },
            gotoDetailOut: function (id, modelName, storeAddress, type, fkCompanyId) {
                var title = "";
                if (type == "out") {
                    title = "旧汽车出库"
                    top.closeTabByPageId("qcgl");
                    top.addTabs({
                        id: 'qcgl',
                        title: title,
                        close: true,
                        url: '/device/sample/oldCarDetail.html?pageType=edit&&id=' + id + "&&isAdd=0&&title="+title,
                    });
                    return;
                } else if (type == "move") {
                    title = "旧汽车移库"
                } else {
                    title = "旧汽车退货"
                }
                top.$.dialog({
                    content: 'url:/page/device/sample/outOldCar.html?sampleId=' + id + "&&storeAddress=" + storeAddress + "&&modelName=" + modelName + "&&type=" + type + "&&fkCompanyId=" + fkCompanyId,
                    title: title,
                    width: 904,
                    height: 565,
                    max: true,
                    min: true,
                    lock: true
                })
            },
            search: function () {
                this.searchParams.brandName = $("#testBran option:selected").text();
                $.wyui.page.queryParams.requestPage = 1;
                $.extend($.wyui.page.queryParams, this.searchParams);
                console.log($.wyui.page.queryParams);
                $.wyui.page.getByPage();
            },
            /*逻辑删除*/
            removeById: function (id, i) {
                if (confirm('确认要删除吗？')) {
                    var that = this;
                    $.wyui.postMethod("/deviceDisplace/delById.json", {"id": id}, function (r) {
                        if (r.records == '删除成功') {
                            alert("删除成功");
                            location.reload();
                        } else {
                            alert("删除失败");
                        }

                    });
                }
            },
            isActive: function (item) {
                var that = this;
                if (that.searchParams.replacementType == item) {
                    return true;
                }
            },
            convertAuditFlagToName: function (item) {
                //auditFlag:-1,0,1,2
                switch (item.auditFlag) {
                    case -1:
                        return "-";
                        break;
                    case 0:
                            return "<span style='color:red;'>待-" + item.auditName + "-审核</span>";
                        break;
                    case 1:
                        return "已通过";
                        break;
                    case 2:
                        return "已驳回";
                        break;
                    default :
                        break;
                }
            },
            showABtn: function (item, btnName) {
                switch (btnName) {
                    case 'look':
                        switch (item.auditFlag) {
                            case -1:
                                return false;
                                break;
                            case 0:
                                return currentUser.id != item.auditId;
                                break;
                            case 1:
                                return true;
                                break;
                            case 2:
                                return true;
                                break;
                        }
                        return true;
                        break;
                    case 'edit':
                        return ( (item.createUserId == currentUser.id) || (currentUser.roleName == '订货支持'||currentUser.name=='曹国玉'|| (currentUser.roleName == '销售管理'&&item.state=='交付在途')) ) && (item.auditFlag != 0);
                        break;
                    case 'audit':
                        return item.auditFlag == 0 && currentUser.id == item.auditId;
                        break;
                    case 'out':
                        return ( item.auditFlag ==1 && item.state == '库存' ) && (item.createUserId == currentUser.id || currentUser.roleName == '订货支持');
                        break;
                    case 'return':
                        return currentUser.roleName=='订货支持'&&('库存,寄存,已交').indexOf(item.state)!=-1;
                        break;
                    case 'del':
                        return currentUser.roleName=='订货支持';
                        break;
                    default:
                        break;
                }
            },
        },
        mounted: function () {
            var that = this;
            $.wyui.postMethod("/deviceDisplace/getDisplaceListNew.json", that.searchParams, function (r) {
                that.list = r.records;
                that.count = r.countList;
                for (var i = 0; i < that.stateList.length; i++) {
                    if (that.stateList[i].name == '全部') {
                        that.stateList[i].name = '全部' + '(' + that.count.allCount + ')';
                    } else if (that.stateList[i].name == '提车在途') {
                        that.stateList[i].name = '提车在途' + '(' + that.count.tcCount + ')';
                    } else if (that.stateList[i].name == '库存') {
                        that.stateList[i].name = '库存' + '(' + that.count.kcCount + ')';
                    } else if (that.stateList[i].name == '交付在途') {
                        that.stateList[i].name = '交付在途' + '(' + that.count.jfCount + ')';
                    } else if (that.stateList[i].name == '已交') {
                        that.stateList[i].name = '已交' + '(' + that.count.yjCount + ')';
                    } else if (that.stateList[i].name == '移库在途') {
                        that.stateList[i].name = '移库在途' + '(' + that.count.ykCount + ')';
                    } else if (that.stateList[i].name == '退货在途') {
                        that.stateList[i].name = '退货在途' + '(' + that.count.thCount + ')';
                    } else if (that.stateList[i].name == '已退货') {
                        that.stateList[i].name = '已退货' + '(' + that.count.ythCount + ')';
                    }
                }
            });
            $.wyui.postMethod('/company/getCompanyByUserId.json', {userId: that.searchParams.userId}, function (r) {
                that.itemsCom = r;
            });
            $.wyui.postMethod('/deviceDisplace/getDisplaceByBrandName.json',{'type':"2"}, function (r) {
                that.itemsBran = r;
            })

        }
    });
</script>
<script>
    /************************滚动加载******************************/
    var divscroll = document.getElementById('scrollDiv');

    function divScroll() {
        var wholeHeight = divscroll.scrollHeight;
        var scrollTop = divscroll.scrollTop;
        var divHeight = divscroll.clientHeight;
        console.log(scrollTop + divHeight, wholeHeight)
        if (scrollTop + divHeight >= wholeHeight - 2) {
//            alert('滚动到底部了！');
            if (isLoad) {
                isLoad = false;
                setTimeout($.wyui.page.getByPage("scroll"), 1000);

            }

            //这里写动态加载的逻辑，比如Ajax请求后端返回下一个页面的内容
        }

    }
    divscroll.onscroll = divScroll;
</script>
<script>
    //初始化FixedTable
    $(".fixed-table-box").fixedTable();
</script>
</body>
</html>